package com.mvvm.store.retrofitwithrxjava;



import com.mvvm.store.bean.BannerBean;
import com.mvvm.store.bean.DeliveryParasBean;
import com.mvvm.store.bean.StockUpParasBean;
import com.mvvm.store.bean.User;
import com.mvvm.store.bean.basebean.DeliveryGetListResultBean;
import com.mvvm.store.bean.basebean.DeliveryResultBean;
import com.mvvm.store.bean.basebean.DeliverySubmitParams;
import com.mvvm.store.bean.basebean.DeliverySubmitResultBean;
import com.mvvm.store.bean.basebean.HomeFatherBean;
import com.mvvm.store.bean.basebean.IntoSubmitPramsBean;
import com.mvvm.store.bean.basebean.IntoSubmitResultBean;
import com.mvvm.store.bean.basebean.MeterialInfroResultBean;
import com.mvvm.store.bean.basebean.ResponModel;
import com.mvvm.store.bean.basebean.StockUpGetListResultBean;
import com.mvvm.store.bean.basebean.StockUpResultBean;
import com.mvvm.store.bean.basebean.StockUpSubmitParams;
import com.mvvm.store.bean.basebean.StockUpSubmitResultBean;
import com.mvvm.store.bean.basebean.UserAuthenticationBean;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.PartMap;
import retrofit2.http.Path;
import retrofit2.http.Query;
import retrofit2.http.Streaming;
import retrofit2.http.Url;

/**
 * Created by leo
 * on 2019/8/14.
 * Retrofit 接口请求配置都在这
 */
public interface RetrofitApiService {
    //wanAndroid的，轮播banner的接口
    @GET("banner/json")
    Observable<ResponModel<List<BannerBean>>> getBanner();

    //首页文章,curPage拼接。从0开始
    @GET("article/list/{curPage}/json")
    Observable<ResponModel<HomeFatherBean>> getHomeArticles(@Path("curPage") int curPage);

    //收藏文章列表
    @GET("lg/collect/list/{curPage}/json")
    Observable<ResponModel<HomeFatherBean>> getCollectArticles(@Path("curPage") int curPage);

    //收藏站内文章
    @POST("lg/collect/{id}/json")
    Observable<ResponModel<String>> collectArticle(@Path("id") int id);

    //收藏站外文章
    @FormUrlEncoded
    @POST("lg/collect/add/json")
    Observable<ResponModel<String>> collectOutArticle(@Field("title") String title, @Field("author") String author, @Field("link") String link);

    //取消收藏 -- 首页文章列表
    @POST("lg/uncollect_originId/{id}/json")
    Observable<ResponModel<String>> unCollectByHome(@Path("id") int id);

    //取消收藏 -- 我的收藏列表
    @FormUrlEncoded
    @POST("lg/uncollect/{id}/json")
    Observable<ResponModel<String>> unCollectByMe(@Path("id") int id, @Field("originId") int originId);



    //退出登录
    @GET("user/logout/json")
    Observable<ResponModel<String>> loginOut();

    @POST("user/login")
    @FormUrlEncoded
    Observable<ResponModel<User>> login(@FieldMap HashMap<String, Object> map);

    //Retrofit get请求
    @GET("xiandu/category/wow")
    Observable<String> getGank(@Query("en_name") String en_name);


    //Retrofit post请求
    @POST("add2gank")
    @FormUrlEncoded
    Observable<ResponseBody> postAddGank(@FieldMap HashMap<String, String> map);

    //单张图片上传
    @POST("upload/pic")
    @Multipart
    Observable<ResponModel<String>> uploadPic(@Part("type") RequestBody type, @Part MultipartBody.Part file);


    //单张图片上传
    @POST("upload/picss")
    @Multipart
    Observable<ResponModel<String>> uploadPicss(@Part("type") RequestBody type, @PartMap Map<String, RequestBody> maps);

    //Retrofit下载文件
    @GET
    @Streaming
    //10以上用@streaming。不会造成oom，反正你用就是了
    Observable<ResponseBody> downloadFile(@Url String url);

    @GET
    @Streaming
    Observable<ResponseBody> downloadFile(@Url String url, @Header("RANGE") String range);

    //-------------------------------------------------------------------------------------------------------------

    //根据入库订单号获取订单信息
    @GET("app/supplierDeliveryMaterialList")
    Observable<ResponModel<List<MeterialInfroResultBean>>> getMaterialInfo(@Query("deliveryOrderNo") String inStockNumber);

    //查询备货列表数据
    @POST("app/pageQueryStock")
    Observable<ResponModel<List<StockUpResultBean>>> getStockUpList(@Body StockUpParasBean stockUpParasBean);

    //根据订单查询备货列表数据
    @FormUrlEncoded
    @POST("app/stockDetails")
    Observable<ResponModel<List<StockUpGetListResultBean>>> getStockIdList(@Field("stockOrderNo") String stockOrderNo);



    //查询出库列表数据
    @POST("app/page")
    Observable<ResponModel<DeliveryResultBean>> getDeliveryList(
            @Body DeliveryParasBean deliveryParasBean
    );


    //根据出库订单查询对应的需要出库的零件信息
    @GET("/app/getById/{id}")
    Observable<ResponModel<DeliveryGetListResultBean>> getDeliveryDetailsList(@Path("id") String id);


    //入库提交
    @POST("app/commitInStock")
    Observable<ResponModel> submitInto(@Body IntoSubmitPramsBean intoSubmitPramsBean);


    //备货提交
    @POST("app/commitStock")
    Observable<ResponModel<StockUpSubmitResultBean>> stockUpSubmit(@Body List<StockUpSubmitParams> stockUpSubmitParams);

    //出库提交POST /app/submit
    @POST("app/submit")
    Observable<ResponModel> deliverySubmit(@Body DeliverySubmitParams deliverySubmitParamsList);

    //提交用户验证
    @POST("app/validation")
    Observable<ResponModel<String>> userAuthentication(@Body UserAuthenticationBean userAuthenticationBean);


}
